<?php #//v.3.3.0
#///////////////////////////////////////////////////////
#//  COPYRIGHT 2004 Phpauction.org ALL RIGHTS RESERVED//
#///////////////////////////////////////////////////////

require('./includes/config.inc.php');
      

$TIME = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d"),date("Y"));

$NOW = date("YmdHis",$TIME);


//* get ending soon auctions */
$TPL_ending_soon_value = "";
/*
         WHERE closed='0' AND
         suspended='0' AND ";
         $query .= "starts<=".$NOW."
         order by id LIMIT ".$SETTINGS['endingsoonnumber'];    */
         
         
         $query = "select retail,ends,id,title,current_high_bidder,current_bid,pict_url,ends2 from PHPAUCTIONXL_auctions
         WHERE closed='0' AND
         suspended='0' AND ";
         $query .= "starts<=".$NOW."
         order by ends2 LIMIT 0,100";
         
         
$result = mysql_query($query);
$num_auction = mysql_num_rows($result);

$jsenddate = "";

$jsenddate .= substr ($NOW, 4, 2);
$jsenddate .= "/";
$jsenddate .= substr ($NOW, 6, 2);
$jsenddate .= "/";
$jsenddate .= substr ($NOW, 0, 4);
$jsenddate .= " ";


     
if (substr ($NOW, 8, 2) > 12) {
$jsenddate .= substr ($NOW, 8, 2)-12;
$jsampm = "PM";
}
if (substr ($NOW, 8, 2) != 00){
if (substr ($NOW, 8, 2) < 12) {
$jsenddate .= substr ($NOW, 8, 2);
$jsampm = "AM";
}}
if (substr ($NOW, 8, 2) == 12) {
$jsenddate .= substr ($NOW, 8, 2);
$jsampm = "PM";
}
if (substr ($NOW, 8, 2) == 00) {
$jsenddate .= 12;
$jsampm = "AM";
}

$jsenddate .= ":";
$jsenddate .= substr ($NOW, 10, 2);
$jsenddate .= ":";
$jsenddate .= substr ($NOW, 12, 2);
$jsenddate .= " ";
$jsenddate .= $jsampm;
$jsenddate .= "|";

 $i = 0;
while($i < $num_auction) {

$title 	= mysql_result($result,$i,"title");
	$id 	= mysql_result($result,$i,"id");
	$ends 	= mysql_result($result,$i,"ends");
  $high_bidder 	= mysql_result($result,$i,"current_high_bidder");
	$high_bid 	= mysql_result($result,$i,"current_bid");
	$picture_url = mysql_result($result,$i,"pict_url");
	$retail  = mysql_result($result,$i,"retail");
	$nowt	= $TIME;
/*	$difference = mktime(	substr ($ends, 8, 2),
	                      substr ($ends, 10, 2),
	                      substr ($ends, 12, 2),
	                      substr ($ends, 4, 2),
	                      substr ($ends, 6, 2),
	                      substr ($ends, 0, 4))-$nowt;
	if ($difference > 0) {
		$days_difference = floor($difference / 86400);
		$difference = $difference % 86400;
		$hours_difference = floor($difference / 3600);
		$difference = $difference % 3600;
		$minutes_difference = floor($difference / 60);
		$seconds_difference = $difference % 60;
		$ends_string = sprintf("%d%s %02dh:%02dm:%02ds",$days_difference,$MSG_126, $hours_difference,$minutes_difference,$seconds_difference);
	} else {
		$ends_string = $MSG_911;
	}

	#// Check bold and highlighted options
	$ISBOLD = FALSE;
	$ISHIGHLIGHTED = FALSE;
         */

$jsenddate .= $id;
	$jsenddate .= "|";
	$jsenddate .= "1";
$jsenddate .= "|";
$jsenddate .= substr ($ends, 4, 2);
$jsenddate .= "/";
$jsenddate .= substr ($ends, 6, 2);
$jsenddate .= "/";
$jsenddate .= substr ($ends, 0, 4);
$jsenddate .= " ";

if (substr ($ends, 8, 2) > 12) {
$jsenddate .= substr ($ends, 8, 2)-12;
$jsampm = "PM";
}
if (substr ($ends, 8, 2) != 00) {
if (substr ($ends, 8, 2) < 12) {
$jsenddate .= substr ($ends, 8, 2);
$jsampm = "AM";
}
}
if (substr ($ends, 8, 2) == 12) {
$jsenddate .= substr ($ends, 8, 2);
$jsampm = "PM";
}
if (substr ($ends, 8, 2) == 00) {
$jsenddate .= substr ($ends, 8, 2);
$jsampm = "AM";
}

$jsenddate .= ":";
$jsenddate .= substr ($ends, 10, 2);
$jsenddate .= ":";
$jsenddate .= substr ($ends, 12, 2);
$jsenddate .= " ";
$jsenddate .= $jsampm;
$jsenddate .= "|";
$jsenddate .= $title;
$jsenddate .= "|";
$jsenddate .= $high_bidder;
$jsenddate .= "|";
$jsenddate .= print_money_nosymbol($high_bid);
$jsenddate .= "|";
$jsenddate .= $picture_url;
$jsenddate .= "|";
$jsenddate .= print_money_nosymbol($retail);
$jsenddate .= "|";


$i++;
}









      $myFile = "cronfiles/get_time2.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $jsenddate;
fwrite($fh, $stringData);
fclose($fh);

       
$query_settings = "select * from PHPAUCTIONXL_proxybid_settings where id='1'";
                             $query_settings2a =  mysql_query ($query_settings);
                                $activated = mysql_result($query_settings2a,0,"activated");
              if ( $activated == 1 ) {
include 'autobidder2cron.php';
                 }

     /*

$query_settings2 = "select * from PHPAUCTIONXL_unique_settings where id='1'";
                             $query_settings3 =  mysql_query ($query_settings2);
                                $activated2 = mysql_result($query_settings3,0,"activated");
        if ( $activated2 == 1 ) {
include 'uniquecron.php';
      }
       */ 


    /*
    
     $ProcessState = 0;
     $PID = shell_exec("nohup unique.php > /dev/null & echo $!");
     exec("ps $PID", $ProcessState);
      echo $PID;
      
      
      echo $ProcessState;
     
      if ( count($ProcessState) >= 2 )
      {
                          echo $PID;
      echo $ProcessState;
      
     if(exec::is_running($PID)){
           exec("kill -KILL $PID");      
      }
     }
           
     */      
    
           
?> 